<?php
class Contact extends ContactPeer
{
	var $className = __CLASS__;
	public $captcha;
	/**
	 * Returns the static model of the specified AR class.
	 * @return Contact the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
            array('email', 'email', 'checkMX'=>true),
			array('full_name, phone, email, title, content', 'required'),
			array('full_name, title', 'length', 'max'=>250),
			array('phone', 'length', 'max'=>20),
			array('email', 'length', 'max'=>160),
			array('content', 'length', 'max'=>1000),
			array('ip', 'length', 'max'=>50),

//			array('captcha', 'captcha', 'allowEmpty'=>!extension_loaded('gd'), 'on'=>'create'),
			
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('id, full_name, phone, email, title, content, ip, contact_date', 'safe', 'on'=>'search'),
		);
	}
	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id);

		$criteria->compare('full_name',$this->full_name,true);

		$criteria->compare('phone',$this->phone,true);

		$criteria->compare('email',$this->email,true);

		$criteria->compare('title',$this->title,true);

		$criteria->compare('content',$this->content,true);

		$criteria->compare('ip',$this->ip,true);

		$criteria->compare('contact_date',$this->contact_date,true);

		return new CActiveDataProvider(get_class($this), array(
			'criteria'=>$criteria,
		));
	}
}